/**
 * 
 */
package com.java.test.activity.dto;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.time.ZoneOffset;

import org.springframework.jdbc.core.RowMapper;

import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * @author 活动详情dto
 *
 */
public class ActivityManageInfo implements RowMapper<ActivityManageInfo> {

	// 活动id
	private int id;

	// 活动名称
	private String activityName;

	// 活动图片
	private String imgUrl;

	// 活动跳转地址
	private String activitJumpUrl;

	// 活动开始时间
	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private LocalDateTime startTime;

	// 活动结束时间
	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private LocalDateTime endTime;

	// 活动状态 1:未开始  ：2 开始，3结束
	private int status;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getActivityName() {
		return activityName;
	}

	public void setActivityName(String activityName) {
		this.activityName = activityName;
	}

	public String getImgUrl() {
		return imgUrl;
	}

	public void setImgUrl(String imgUrl) {
		this.imgUrl = imgUrl;
	}

	public String getActivitJumpUrl() {
		return activitJumpUrl;
	}

	public void setActivitJumpUrl(String activitJumpUrl) {
		this.activitJumpUrl = activitJumpUrl;
	}

	public LocalDateTime getStartTime() {
		return startTime;
	}

	public void setStartTime(LocalDateTime startTime) {
		this.startTime = startTime;
	}

	public LocalDateTime getEndTime() {
		return endTime;
	}

	public void setEndTime(LocalDateTime endTime) {
		this.endTime = endTime;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	@Override
	public ActivityManageInfo mapRow(ResultSet rs, int rowNum) throws SQLException {

		ActivityManageInfo info = new ActivityManageInfo();

		info.setId(rs.getInt("id"));
		info.setActivitJumpUrl(rs.getString("activit_jump_url"));
		info.setActivityName(rs.getString("activity_name"));
		info.setStartTime(rs.getTimestamp("start_time") == null ? null
				: rs.getTimestamp("start_time").toInstant().atZone(ZoneOffset.ofHours(8)).toLocalDateTime());
		info.setEndTime(rs.getTimestamp("end_time") == null ? null
				: rs.getTimestamp("end_time").toInstant().atZone(ZoneOffset.ofHours(8)).toLocalDateTime());

		info.setImgUrl(rs.getString("img_url"));

		info.setStatus(rs.getInt("status"));

		return info;
	}

}
